print('使用变量保存数据并进行加减乘除运算')
a = 321
b = 12
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print('\n')

print('使用 type() 检查变量的类型')
a = 100
b = 12.345
c = 1 + 5j
d = 'hello, world'
e = False
print(type(a))
print(type(b))
print(type(c))
print(type(d))
print(type(e))
print('\n')

print('赋值运算符和复合赋值运算符')
a = 10
b = 2
a += b  # a = a + b
a *= a + 2  # a = a * (a + 2)
print(a)
print('\n')

print('使用 input() 函数获取键盘输入\n '
      '使用 int() 函数将输入的字符串转换成整数\n '
      '使用 print() 函数输出带占位符的字符串\n')
# a = int(input('a = '))
# b = int(input('b = '))
a = 6
b = 3
print('%d + %d = %d' % (a, b, a + b))
print('%d - %d = %d' % (a, b, a - b))
print('%d * %d = %d' % (a, b, a * b))
print('%d / %d = %f' % (a, b, a / b))
print('%d // %d = %d' % (a, b, a // b))
print('%d %% %d = %d' % (a, b, a % b))
print('%d ** %d = %d' % (a, b, a ** b))
print('\n')

print('比较运算符和逻辑运算符的使用')
print('1 == 1', 1 == 1)
print('3 > 2', 3 > 2)
print('1 == 1 and 3 > 2', 1 == 1 and 3 > 2)
print('1 == 1 or 3 > 2', 1 == 1 or 3 > 2)
print('not (1 != 2)', not (1 != 2))
print('\n')

print('将华氏温度转为摄氏温度')
f = 50.6
c = (f - 32) / 1.8
print('%.1f华氏度 = %.1f摄氏度' % (f, c))
print(f'{f:.1f}华氏度 = {c:.1f}摄氏度')
print('\n')

print('计算圆的周长和面积')
radius = float(3.5)
perimeter = 2 * 3.14 * radius
area = 3.14 * radius ** 2
print('周长 = %.1f' % perimeter)
print('area = %.1f' % area)
print('\n')

print('判断年份是不是闰年')
year = 1224
is_leap = year % 4 == 0 and year % 100 != 0 or year % 400 == 0
print('is_leap = %s' % is_leap)
print('\n')


